Skip to content

test+feat: close rich Markdown preview residuals - #209

Merged
stone16 merged 26 commits into
mainfrom
stone16/issue-207-link-negatives
Aug 1, 2026
Merged

test+feat: close rich Markdown preview residuals#209
stone16 merged 26 commits into
mainfrom
stone16/issue-207-link-negatives

Conversation

@stone16

@stone16 stone16 commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • pin the exact bracketed non-link negatives from test+feat: pin the link-predicate negatives and close the non-link v3 preview dead end #207 and prove the broad return "[" in source mutation is rejected
  • extend the frozen-v1 import preview handoff to v3-accepted emphasis, inline code, and strikethrough without importing or executing the v3 compiler in the console
  • keep malformed mixed rich Markdown generic and content-free, including link, structural, fence, angle-literal, and HTML edge cases
  • update ADR-0093 and status wording to the implemented handoff contract

Closes #207

Verification

  • make lint — PASS (All checks passed!)
  • make typecheck — PASS (mypy: Success: no issues found in 494 source files; TypeScript SDK/action/bot checks passed)
  • make test — PASS (2480 passed in 68.94s)
  • targeted compiler tests — PASS (17 passed, 69 deselected)
  • preview HTTP integration tests — PASS (28 passed in 15.29s)
  • make db-reset — PASS on the generated worktree-specific PostgreSQL 17 + pgvector harness
  • make check — all targets completed; the PTY lost its closing buffered chunk, so results were independently checked from captured component output and fresh artifacts:
    • integration target completed with exit 0; collection reports 726/730 tests collected (4 deselected)
    • M0 security evidence: 170/170 registered tests passed, no collection errors, m0SecurityDecision: pass, bound to commit 283495547d728257508c14fa530f33d39f250f1a
    • third-party artifacts: wheel PASS, sdist PASS, npm PASS, container NOT_PRODUCED (maintainer decision)
  • final Standards review — PASS
  • final issue-spec review — PASS
  • git diff --check — PASS

Mutation evidence

Temporarily replacing the link predicate with return "[" in source caused the named negative test to report 5 failures and 1 pass. The production predicate was restored; the committed test passes all six cases.

The worktree-specific database harness was stopped after verification; its disposable data volume was preserved.

Summary by CodeRabbit

  • New Features

    • Import previews now recognize accepted Markdown such as emphasis, inline code, strikethrough, links, headings, lists, and thematic breaks.
    • Supported rich Markdown can be handed off to the activated file scan while preserving existing content and revision behavior.
  • Bug Fixes

    • Improved validation prevents malformed, mixed, oversized, or unsupported Markdown from receiving an incorrect scan handoff.
    • Refused content remains content-free in preview responses.
  • Documentation

    • Updated compatibility guidance for rich Markdown across supported versions.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9cc10348-fc1e-45cc-9faa-8484a4ffe6d1

📥 Commits

Reviewing files that changed from the base of the PR and between 2834955 and 0bee808.

📒 Files selected for processing (6)
  • STATUS.md
  • adapters/parsers/ragflow_markdown.py
  • docs/decisions/0093-activate-leased-rich-markdown-and-revision-link-graph.md
  • engine/supply/markdown.py
  • tests/integration/test_import_preview_requires_confirm.py
  • tests/unit/test_compiler_runner_acceptance.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • STATUS.md

📝 Walkthrough

Walkthrough

The PR centralizes accepted rich Markdown detection and validation. Import preview handoff now supports accepted v3 links, emphasis, inline code, and strikethrough. Tests cover valid, malformed, oversized, and concealed constructs. Status and ADR documentation reflect the expanded compatibility behavior.

Changes

Rich Markdown handoff

Layer / File(s) Summary
Centralize rich Markdown detection and validation
engine/supply/markdown.py, engine/supply/__init__.py, adapters/parsers/ragflow_markdown.py, tests/unit/test_markdown_compiler.py
Adds shared construct detection, inline validation, token counting, HTML-block handling, public exports, parser integration, and unit coverage.
Route accepted constructs through import preview
adapters/http/ui_api.py, tests/integration/test_import_preview_requires_confirm.py
Decodes Markdown as UTF-8, checks accepted constructs and compiler refusals, and hands eligible v3-only imports to the leased File scan path. Integration tests cover supported and refused payloads.
Verify compiler and handoff agreement
tests/unit/test_compiler_runner_acceptance.py
Verifies that accepted inline constructs pass both predicates and compilation. Refused malformed, oversized, and concealed block constructs remain rejected.
Record v3 compatibility behavior
STATUS.md, docs/decisions/0093-activate-leased-rich-markdown-and-revision-link-graph.md
Updates status and ADR text for accepted rich links, emphasis, inline code, and strikethrough imports.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ImportPreview
  participant MarkdownCompiler
  participant AcceptedConstructDetector
  participant LeasedFileScan
  ImportPreview->>MarkdownCompiler: compile import preview
  MarkdownCompiler-->>ImportPreview: return refusal and unsupported construct
  ImportPreview->>AcceptedConstructDetector: validate accepted inline construct
  AcceptedConstructDetector-->>ImportPreview: return acceptance result
  ImportPreview->>LeasedFileScan: hand off eligible content
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the closure of remaining rich Markdown preview cases.
Linked Issues check ✅ Passed The changes address all coding objectives in [#207], including negative predicate tests, v3 construct handoff, and content-free malformed refusals.
Out of Scope Changes check ✅ Passed The code, tests, exports, status update, and ADR changes directly support the linked issue objectives.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stone16/issue-207-link-negatives

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 283495547d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/supply/markdown.py
Comment on lines +727 to +730
elif candidate[0] == fence[0] and len(candidate) >= len(fence):
if not fence_body_has_content:
return False
fence = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require a bare closing fence before handing off

When an otherwise accepted document contains a fenced block whose would-be closer has a suffix, such as ```oops, this condition treats that line as the closing fence because it checks only the marker character and length. The v3 parser's _is_closing_fence requires the marker to be followed only by whitespace, so the worker instead refuses the document as CODE_BLOCK; the preview therefore returns an actionable scan handoff for malformed syntax that ADR-0093 says must remain generically unavailable. Validate the complete closing-fence line using the same rule as the v3 parser.

AGENTS.md reference: AGENTS.md:L22-L24

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@engine/supply/markdown.py`:
- Around line 715-750: Update _has_closed_rich_html_block and its call from
contains_only_accepted_rich_markdown_inline so the closing-tag search is limited
to the source from the current opening line onward, preventing an earlier
same-tag closing element from satisfying a later unclosed block. Preserve the
existing first-line call behavior for the other caller.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d5211060-2bc7-4251-922a-2058dca710bb

📥 Commits

Reviewing files that changed from the base of the PR and between 6236ff2 and 2834955.

📒 Files selected for processing (7)
  • STATUS.md
  • adapters/http/ui_api.py
  • docs/decisions/0093-activate-leased-rich-markdown-and-revision-link-graph.md
  • engine/supply/__init__.py
  • engine/supply/markdown.py
  • tests/integration/test_import_preview_requires_confirm.py
  • tests/unit/test_markdown_compiler.py

Comment thread engine/supply/markdown.py Outdated
@stone16

stone16 commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

E3 substantive findings are fixed on commits d0d4f40 through 0bee808.

  • Finding 1: contains_only_accepted_rich_markdown_inline now refuses every reproduced v3-invalid block shape outside fences before offering the leased scan handoff: list-indented quote/ATX/fence, setext blockquote, invalid HTML/table adjacency and ordering, control-bearing HTML/angle literals, and oversized indivisible list/table blocks. The accepted handoff corpus remains pinned by predicate-to-v3 compiler agreement tests, and the HTTP preview tests assert the invalid cases stay on the generic content-free 503 path.
  • Finding 2: _validate_rich_closed_grammar again performs section-kind-aware inspection, so forged compiler-runner child output for (LIST, list-indented quote), (LIST, list-indented ATX), and (HEADING, setext blockquote) is rejected at parent-side reconstruction. A parametrized constructor test pins all three trust-boundary negatives.
  • Minor findings: STATUS.md and ADR-0093 now qualify the trigger as the closed v1-refusal plus whole-document rich-syntax check, and the predicate-to-v3 consistency suite covers the accepted corpus. Both independent final reviews passed committed HEAD 0bee808.

Verification with repository-pinned Node 22.12.0:

  • make lint — PASS (All checks passed!)
  • make typecheck — PASS (Success: no issues found in 494 source files; all TypeScript checks passed)
  • make test — PASS (2503 passed in 53.32s)
  • make integration — PASS (738 passed, 4 deselected, 3 SQLAlchemy GC warnings in 704.14s)

One earlier full integration attempt had a timing-sensitive scheduler ordering failure (733 passed, 4 deselected, 1 failed); the isolated scheduler plus preview regression rerun passed (13 passed), and the final full integration rerun above passed. Branch pushed at 0bee808; PR remains open and unmerged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bee808c0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engine/supply/markdown.py
Comment on lines +766 to +779
if _RICH_SETEXT_PATTERN.fullmatch(line) is not None:
if (
previous_line is not None
and previous_line.strip()
and unsupported_rich_markdown_inline(previous_line.strip()) is not None
):
return False
list_open = False
previous_line = line
continue
if _THEMATIC_BREAK_PATTERN.fullmatch(line) is not None:
list_open = False
previous_line = line
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject indented separators while a list is open

stometa, when an accepted rich construct is followed by a list continuation such as - item\n ordinary\n ---, this branch treats the indented separator as a standalone setext/thematic marker and returns a scan handoff. The v3 parser instead processes it as an indented list continuation and refuses it as FRONTMATTER_OR_RULE, so malformed input bypasses the ADR-0093 requirement that compilation refusals remain generically unavailable. Check list-continuation context before handling setext and thematic separators.

AGENTS.md reference: AGENTS.md:L22-L24

Useful? React with 👍 / 👎.

Comment thread engine/supply/markdown.py
Comment on lines +791 to +796
html_block_end = index
while (
html_block_end + 1 < len(lines)
and lines[html_block_end + 1].strip()
):
html_block_end += 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve setext precedence before grouping HTML blocks

stometa, for input such as [ok](note.md)\n\n<div>ok</div>\n===\n<div>bad, this loop groups all three consecutive lines into a closed HTML block and the preview returns a scan handoff. The v3 parser first interprets <div>ok</div> plus === as a setext heading, then refuses the unclosed <div>bad as HTML; consequently a malformed document receives the actionable handoff that ADR-0093 reserves for v3-accepted documents. Mirror the compiler's setext lookahead before extending the HTML block.

AGENTS.md reference: AGENTS.md:L22-L24

Useful? React with 👍 / 👎.

@stone16
stone16 merged commit 41d9806 into main Aug 1, 2026
1 of 2 checks passed
@stone16
stone16 deleted the stone16/issue-207-link-negatives branch August 1, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test+feat: pin the link-predicate negatives and close the non-link v3 preview dead end

1 participant